package com.cxrj.zhsq.housePropertyManage.controller;

import java.io.IOException;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.cxrj.zhsq.housePropertyManage.entity.PropertyMember;
import com.cxrj.zhsq.housePropertyManage.service.PropertyMemberService;

@RestController
public class PropertyMemberController {
	@Resource
	private PropertyMemberService propertyMemberService;
	
	/**
	 * 查询所有
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("selectMemberList")
	public Map<String, Object> selectMemberList(HttpServletRequest request,HttpServletResponse response){
		return propertyMemberService.selectMemberList(request,response);
	}
	
	/**
	 * 查询业主
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("selectOwnerMember")
	public Map<String, Object> selectOwnerMember(HttpServletRequest request,HttpServletResponse response){
		return propertyMemberService.selectOwnerMember(request,response);
	}
	
	/**
	 * 添加
	 * @param propertyMember
	 * @param request
	 * @return
	 */
	@RequestMapping("insertMember")
	public Map<String, Object> insertMember(PropertyMember propertyMember,HttpServletRequest request){
		return propertyMemberService.insertMember(propertyMember,request);
	}
	
	/**
	 * 更新
	 * @param propertyMember
	 * @param request
	 * @return
	 */
	@RequestMapping("updateMember")
	public Map<String, Object> updateMember(PropertyMember propertyMember,HttpServletRequest request){
		return propertyMemberService.updateMember(propertyMember,request);
	}
	
	@RequestMapping("selectMemberDetails")
	public Map<String, Object> selectMemberDetails(String id){
		return propertyMemberService.selectMemberDetails(id);
	}
	
	/**
	 * 删除
	 * @param propertyMember
	 * @return
	 */
	@RequestMapping("deleteMember")
	public Map<String, Object> deleteMember(PropertyMember propertyMember){
		return propertyMemberService.deleteMember(propertyMember);
	}
	
	/**
	 * 导入
	 * @param file
	 * @param request
	 * @return
	 * @throws IOException
	 */
	@RequestMapping("insertMemberList")
	public Map<String, Object> insertMemberList(@RequestParam(value="file") MultipartFile file,HttpServletRequest request) throws IOException{
		return propertyMemberService.insertMemberList(file,request);
	}

}
